<?php
function create_order_no(){
	global $db;
	$db->Execute("update `orders_number` set `order_no` =`order_no`+ 1 LIMIT 1");
	$query = "SELECT `order_no` FROM `orders_number` LIMIT 1";
	$orders=$db->Execute($query);
	if ($orders->RecordCount()>0) {
	  $ono = add_no_lenght($orders->fields['order_no']);
	}
	return $ono;
}

function add_no_lenght($num,$length=8){
    $outStr=strval($num); 
    for ($i=strlen($outStr)+1;$i<=$length;$i++){ 
        $outStr="0"."$outStr"; 
    }
    return $outStr;     
}

?>